#include<bits/stdc++.h>
using namespace std;
//#define int long long

struct node {
	string s;
	int idx;
} s[100];

signed main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> s[i].s;
		s[i].idx = i;
	}
	sort(s + 1, s + n + 1, [](node x, node y) {
		if (x.s.size() != y.s.size())
			return x.s.size() > y.s.size();
		else
			return x.s > y.s;
	});
	cout << s[1].idx << endl << s[1].s;
	return 0;
}
